package com.it.arktech.service;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.it.arktech.model.Member;
import com.it.arktech.repository.MemberRepository;

@Service
public class ServiceImpl implements SoftwayService {

	@Autowired
	MemberRepository memberRepository;

	public ServiceImpl() {
	}
	
	@Autowired
	public ServiceImpl(MemberRepository memberRepository) {
		super();
		this.memberRepository = memberRepository;
	}

	public List<Member> findAllMember() throws SQLException {
		try {
			List<Member> findList = memberRepository.findAllMember();
			return findList;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	public Member findMemberById(int id) throws SQLException {
		try {
			Member member = memberRepository.findMemberById(id);
			return member;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	public void insertMember(Member member) throws SQLException {
		try{
			memberRepository.insertMember(member);
		}catch(Exception e){
			e.printStackTrace();
		}
	}

	public void updateMemberById(int id) throws SQLException {
		try{
			memberRepository.deleteMemberById(id);
		}catch(Exception e){
			e.printStackTrace();
		}
	}

	public void deleteMemberById(int id) throws SQLException {
		try{
			memberRepository.deleteMemberById(id);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
